package com.cskaoyan.maven.jdbc;


import java.sql.*;

/**
 * @ClassName com.cskaoyan.maven.jdbc.Transmission
 * @Description: TODO
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2023/2/8 15:42
 * @Version V1.0
 **/
public class Transmission {

    public static void main(String[] args) {
        //测试druid---依赖是可以传递过来的
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb4", "root", "123456");
            PreparedStatement preparedStatement = connection.prepareStatement("select * from account");
            ResultSet resultSet = preparedStatement.executeQuery();
            resultSet.next();
            String name = resultSet.getString("name");
            System.out.println(name);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            //关闭，为了省时间，我就不去写了
        }
    }
}
